//
//  SearchFunsViewController.m
//  ioschishan
//
//  Created by 马田成 on 2017/7/18.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "SearchFunsViewController.h"
#import "ConcernAndFunsOtherVC.h"
#import "ConcernAndFunsTableViewCell.h"



@interface SearchFunsViewController ()<UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataArr;
@property (nonatomic, strong) UILabel *labelOfl;
@property (weak, nonatomic) IBOutlet UIView *viewSearch;
@property (weak, nonatomic) IBOutlet UITextField *searchTF;
@property (weak, nonatomic) IBOutlet UIView *viewRoot;


@end

@implementation SearchFunsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creationView];
    self.searchTF.delegate = self;
    self.searchTF.returnKeyType = UIReturnKeySearch;
    
    
    self.view.backgroundColor = [UIColor colorWithRed:245 / 255.0f green:245 / 255.0f blue:245 / 255.0f alpha:1];
    
    
    // Do any additional setup after loading the view from its nib.
}
- (IBAction)cancelButton:(UIButton *)sender {

    [self dismissViewControllerAnimated:YES completion:nil];

}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    NSLog(@"点击了搜索");
    
    self.labelOfl.hidden = YES;
    UIView *viewOne = [[UIView alloc] init];
    [self.view addSubview:viewOne];
    viewOne.backgroundColor =[UIColor colorWithRed:245 / 255.0f green:245 / 255.0f blue:245 / 255.0f alpha:1];
    [viewOne mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.searchTF.mas_bottom).with.offset(7);
        make.left.equalTo(self.view);
        make.right.equalTo(self.view);
        make.height.offset(10);
        
    }];
    

    UIView *headView = [[UIView alloc] init];
    [self.view addSubview:headView];
    [headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(viewOne.mas_bottom);
        make.left.equalTo(self.view);
        make.right.equalTo(self.view);
        make.height.offset(35);
        
    }];
    headView.backgroundColor = [UIColor whiteColor];

    UILabel *labelxi = [[UILabel alloc] init];
    [headView addSubview:labelxi];
    [labelxi mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headView).with.offset(13);
        make.left.equalTo(self.view).with.offset(15);
        make.height.offset(13);
        make.right.equalTo(self.view);
        
    }];
    labelxi.text = @"联系人";
    labelxi.textColor =[UIColor colorWithRed:155.0f/ 255.0f green:155.0f/ 255.0f blue:155.0f/ 255.0f alpha:1];
    labelxi.font = [UIFont systemFontOfSize:13];
    
    UILabel *oneLabel = [[UILabel alloc] init];
    [self.view addSubview:oneLabel];
    [oneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headView.mas_bottom);
        make.right.equalTo(self.view);
        make.left.equalTo(self.view);
        make.height.offset(1);
        
    }];
    oneLabel.backgroundColor = [UIColor lightGrayColor];
    
    self.tableView = [[UITableView alloc] init];
    self.tableView.frame = CGRectMake(0, 116, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - 116);
    
    self.tableView.tableFooterView = [[UITableView alloc] initWithFrame:CGRectZero];
    
    self.tableView.backgroundColor = [UIColor whiteColor];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    //   self.tableView.estimatedRowHeight = 400;
    //   self.tableView.separatorStyle = UITableViewCellAccessoryNone;去掉分割线

    [self.view addSubview:self.tableView];
    

    [self regeditCell];
    
    
    
    return YES;
}

- (void)creationView{
    
    

    self.labelOfl = [[UILabel alloc] init];
    [self.view addSubview:self.labelOfl];
    [self.labelOfl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.searchTF.mas_bottom).with.offset(30);
        make.centerX.equalTo (self.view);
        make.height.offset(14);

    }];
    self.labelOfl.text = @"搜索联系人";
    self.labelOfl.font = [UIFont systemFontOfSize:14];
    self.labelOfl.textColor = [UIColor colorWithRed:155.0f/ 255.0f green:155.0f/ 255.0f blue:155.0f/ 255.0f alpha:1];

    
    self.viewSearch.backgroundColor = [UIColor colorWithRed:245 / 255.0f green:245 / 255.0f blue:245 / 255.0f alpha:1];
  
}
- (void)data{
    
    
//    _dataArr = [NSMutableArray array];
//    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
//    NSString *token = [PublicFunction getConfigWithKey:@"token"];
//    [productParams setValue:token forKey:@"token"];
//    
//    [[MNetworkHandler sharedInstance]conURL:Home_MemberGoodsOrder networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
//        
//        
//        if ([[returnData objectForKey:@"code"]intValue]==1) {
//            
//            _dataArr = [returnData objectForKey:@"data"];
//            NSLog(@"!!!!!!!!!!!!!!!%@", _dataArr);
//            
//            [self.tableView reloadData];
//            
//            
//            
//        }
//        
//        else {
//            
//            //                [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
//            
//        }
//        
//    } failureBlock:^(NSError *error) {
//        
//        NSLog(@"%@",error);
//        
//        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
//        
//    }];
    
    
    
    
}

- (void)regeditCell{
    
    [self.tableView registerNib:[UINib nibWithNibName:@"ConcernAndFunsTableViewCell" bundle:nil] forCellReuseIdentifier:@"ConcernAndFunsTableViewCell"];
    
}
#pragma mark - ---------- Section的数量 ----------
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

#pragma mark - ---------- 每个Section的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0;
}

#pragma mark - ---------- Cell的数量 ----------
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 15;
    
    
}

#pragma mark - ---------- 每个Cell的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    return 70;
    
}

#pragma mark - ---------- 每个Cell的内容 ----------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    ConcernAndFunsTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"ConcernAndFunsTableViewCell" forIndexPath:indexPath];
    
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    
    
    return cell;
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
